﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>个人红包明细-微街秀管理后台</title>
     <link href="../../Client/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="../css/admin.css" rel="stylesheet" type="text/css" />
<style>
body{ background-color:White; font-size:13px;}
table{border-collapse: collapse;border: none;width:100%; text-align:center;}
td{border: solid #ccc 1px;color:Black; height:26px;}
td a{ text-decoration:none;}
.td1,.td2,.td3,.td6{width:100px; font-weight:bold; text-align:center;}
.td4,.td5{width:160px; font-weight:bold; text-align:center;}
.td4{width:50px;}
/*分页*/
.pager_style{width:100%;height:30px;margin-top:10px;text-align:left;color:#909090;}
.pager_style li{font-size:14px;}
.pager_style .page_num{height:100%;font-size:0;display:inline-block; float:left;}
.pager_style .page_num li{height:100%;border:1px solid #eeeeee;padding:0 10px;margin-right:5px;line-height:30px;display:inline-block;cursor:pointer;float:left;}
.pager_style .page_num li:hover{border:1px solid #f37b0b;background-color:#f37b0b;color:White;}

/*分页 选中当页样式*/
.pager_style .page_num .active{border:1px solid #f37b0b;background-color:#f37b0b;color:White;cursor:default;}
/*分页 不可用样式*/
.pager_style .page_num .disable{background-color:#f1f1f1;}
.pager_style .page_num .disable:hover{border:1px solid #eeeeee;background-color:#f1f1f1;color:#909090;}

.pager_style .page_info{display:none;float:left;}
.pager_style .page_info li{display:inline-block;margin-left:10px;float:left;line-height: 30px;}
#direction1,#direction2{ padding-left:10px;}
</style>
    <script src="../js/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="../js/base.js" type="text/javascript"></script>
    <script src="../js/ajax-data.js" type="text/javascript"></script>
    <script src="../js/Pager.js" type="text/javascript"></script>
    <script src="../js/dialog.js" type="text/javascript"></script>
</head>
<body class="mainbody">
<div class="navigation"><a href="javascript:" class="back" onclick="back()">后退</a>首页 &gt; 交易管理 &gt; <span class="headtitle">红包交易明细</span></div>
<hr style="margin-top:0px;">
<div style="width:780px; margin-left:auto; margin-right:auto;">
<div style="height:30px">微街秀ID:<input type="text" id="userid" name="userid" style="width:80px;" />
     类型:<select id="direction">
                <option value="-1">不限</option>
                <option value="1">收入</option>
                <option value="2">支出</option>
            </select>

    <input type="button" id="btn" value="搜 索" onclick="submits()" /></div> 

 <div style=" line-height:20px;">

 总收入：<span id="direction1">0</span>元&nbsp;&nbsp;&nbsp; <br />
 总支出：<span id="direction2">0</span>元 (已审:<span id="state1">0</span>元&nbsp; 未审:<span id="state0">0</span>元&nbsp; 拒绝:<span id="state2">0</span>元) 
 余额: <span id="balance">0</span>元
 </div>
  
 <div style=" line-height:22px;">金额误差：<span id="wucha" style="color:Red;">0</span>元</div>
 <div style=" line-height:22px;">本次提现：<span id="amount">0</span>元</div>
 <div style=" line-height:22px;">状态：<span id="state"></span></div>
  <table id="list">
    </table>
 <div class="pager_style">
    <ul class="page_num"></ul>
    <ul class="page_info">
        <li>总数:<span id="count">0</span></li>
        <li>每页:<span id="pageSize">0</span></li>
        <li>页数:<span id="pageToal">0</span></li>
    </ul>
</div>
<input type="hidden" id="pagecount" value="0" />
</div>
<div style="clear:both; width:700px; text-align:center; margin:0px auto 0px auto">
    <input type="button" class="btnSubmit" value="返回列表" onclick="back()">
</div>
 <script>
     $(function () {
         GetList(1);
         GetTotal();
         setInterval(SetState, 500);
     })

     function GetList(page) {
         if (getQueryString("userid") != null)
             $("#userid").val(getQueryString("userid"));

         var param = "page_index=" + page;
         param += "&userid=" + $("#userid").val();
         param += "&state=" + $("#state").val();
         param += "&direction=" + $("#direction").val();
         param += "&orderid=" + $("#orderid").val();
         $("#list").html("");
         var html = "<tr><td class='td2'>交易金额</td><td class='td4'>类型</td><td class='td5' style='width:70px;'>交易时间</td><td class='td3'>备注</td></tr>";

         AjaxStart("../ajax/fc_record.ashx?getlist_shared", param, function (data) {
             if (data.code != 0) {
                 $("#list").html(html + "<tr><td colspan='8'>" + data.msg + "</td></tr>");
             }
             else {
                 $("#list").html("");
                 var list = data.item.table;
                 for (var i = 0; i < list.length; i++) {
                     var state = '';
                     var direction = "";
                     if (list[i].direction == 1)
                         direction = "收入";
                     else if (list[i].direction == 2)
                         direction = "支出";

                     if (list[i].state == 1)
                         state = "<span style='color: green;'>成功</span>";
                     else if (list[i].state == 0) {
                         if (list[i].callback_date == null)
                             state = "<span style='color:#ccc;'>取消</span>";
                         else
                             state = "<span style='color:red'>失败</span>";
                     }

                     html += "<tr>";
                     html += "<td>" + (list[i].direction == 2 ? "-" + list[i].amount : list[i].amount) + "元</td>";
                     html += "<td>" + direction + "</td>";
                     html += "<td>" + DateFormat(list[i].date) + "</td>";
                     html += "<td style='text-align:left;'>" + (list[i].direction == 2 ? "[提现]" : "[红包]<a href='../../client/fc_detail.aspx?article_id="+list[i].article_id+"' target=\"_blank\">" + list[i].title + "</a>") + (list[i].remark == null ? "" : list[i].remark) + "</td>";
                     html += "</tr>";
                 }

                 $("#list").html(html);
                 var pager = new Pager();
                 $(".page_info").css("display", "block")
                 pager.initPage(page, data.item.itemCount, 20, 5, GetList);
             }
         });
     }

     function GetTotal() {
         var param = "isad=0&userid=" + $("#userid").val();
         if ($("#userid").val() == "")
             return;
         AjaxStart("../ajax/fc_record.ashx?gettotal", param, function (data) {
             if (data.code != 0) {
                 alert(data.msg);
             }
             else {
                 if (data.item.balance == null) {
                     Alert(data.item);
                     return;
                 }
                 $("#balance").html(data.item.balance);
                 $("#state0").html(data.item.state0 == null ? "0" : data.item.state0);
                 $("#state1").html(data.item.state1 == null ? "0" : data.item.state1);
                 $("#state2").html(data.item.state2 == null ? "0" : data.item.state2);

                 $("#direction1").html(data.item.direction1 == null ? "0" : data.item.direction1);
                 var direction2 = parseFloat($("#state0").html()) + parseFloat($("#state1").html()) + parseFloat($("#state2").html()) + data.item.balance;
                 $("#direction2").html(direction2.toFixed(2));
                
             }
         });
     }

     function SetState() {
         $("#amount").html(getQueryString("amount"));
         var ShouRu = parseFloat($("#direction1").html());

         //总支出 = 已提现 + 本次提现 + 已拒绝 + 余额
         var ZhiChu = parseFloat($("#state0").html()) + parseFloat($("#state1").html()) + parseFloat($("#state2").html()) + parseFloat($("#balance").html());

         //误差金额= 总收入 - 总支出
         $("#wucha").html(parseFloat(ShouRu - ZhiChu).toFixed(2));

         if (ShouRu.toFixed(2) - ZhiChu.toFixed(2) < 0) {
             $("#state").html("<span style='color:red'>异常(收入< 支出)</span>");
         }
         else if (ShouRu.toFixed(2) - ZhiChu.toFixed(2) > 0) {
             $("#state").html("<span style='color:red'>异常(收入> 支出)</span>");
         }
         else
             $("#state").html("正常");
     }
    
     function DateFormat(date) {
         return date.toString().replace("T", " ").substring(0, 19)
     }
     function submits() {
         GetList(1);
         GetTotal();
     }     
 </script>
</body>
</html>
